package com.ruoyi.project.search.viewFactoryStorageAge.controller;

import java.util.List;

import com.ruoyi.project.search.viewFactoryStorageAge.domain.ViewFactoryStorageAge;
import com.ruoyi.project.search.viewFactoryStorageAge.service.IViewFactoryStorageAgeService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工厂库龄Controller
 * 
 * @author qxq
 * @date 2024-04-23
 */
@Controller
@RequestMapping("/search/viewFactoryStorageAge")
public class ViewFactoryStorageAgeController extends BaseController
{
    private String prefix = "search";

    @Autowired
    private IViewFactoryStorageAgeService viewFactoryStorageAgeService;

    @GetMapping()
    public String viewFactoryStorageAge()
    {
        return prefix + "/viewFactoryStorageAge";
    }

    /**
     * 查询工厂库龄列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ViewFactoryStorageAge viewFactoryStorageAge)
    {
//        startPage();
        List<ViewFactoryStorageAge> list = viewFactoryStorageAgeService.selectViewFactoryStorageAgeList(viewFactoryStorageAge);
        return getDataTable(list);
    }

    /**
     * 导出工厂库龄列表
     */
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ViewFactoryStorageAge viewFactoryStorageAge)
    {
        List<ViewFactoryStorageAge> list = viewFactoryStorageAgeService.selectViewFactoryStorageAgeList(viewFactoryStorageAge);
        ExcelUtil<ViewFactoryStorageAge> util = new ExcelUtil<ViewFactoryStorageAge>(ViewFactoryStorageAge.class);
        return util.exportExcel(list, "工厂库龄数据");
    }

    /**
     * 新增工厂库龄
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存工厂库龄
     */
    @Log(title = "工厂库龄", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ViewFactoryStorageAge viewFactoryStorageAge)
    {
        return toAjax(viewFactoryStorageAgeService.insertViewFactoryStorageAge(viewFactoryStorageAge));
    }

    /**
     * 修改工厂库龄
     */
    @GetMapping("/edit/{inClassId}")
    public String edit(@PathVariable("inClassId") String inClassId, ModelMap mmap)
    {
        ViewFactoryStorageAge viewFactoryStorageAge = viewFactoryStorageAgeService.selectViewFactoryStorageAgeByInClassId(inClassId);
        mmap.put("viewFactoryStorageAge", viewFactoryStorageAge);
        return prefix + "/edit";
    }

    /**
     * 修改保存工厂库龄
     */
    @Log(title = "工厂库龄", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ViewFactoryStorageAge viewFactoryStorageAge)
    {
        return toAjax(viewFactoryStorageAgeService.updateViewFactoryStorageAge(viewFactoryStorageAge));
    }

    /**
     * 删除工厂库龄
     */
    @Log(title = "工厂库龄", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(viewFactoryStorageAgeService.deleteViewFactoryStorageAgeByInClassIds(ids));
    }
}
